\(\int x \cos ^2(x) \cot ^2(x) \, dx\) [204]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [C] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [F(-2)]
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 10, antiderivative size = 33 \[ \int x \cos ^2(x) \cot ^2(x) \, dx=-\frac {3 x^2}{4}-\frac {\cos ^2(x)}{4}-x \cot (x)+\log (\sin (x))-\frac {1}{2} x \cos (x) \sin (x) \]

[Out]

-3/4*x^2-1/4*cos(x)^2-x*cot(x)+ln(sin(x))-1/2*x*cos(x)*sin(x)

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 33, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {4493, 3391, 30, 3801, 3556} \[ \int x \cos ^2(x) \cot ^2(x) \, dx=-\frac {3 x^2}{4}-\frac {\cos ^2(x)}{4}-x \cot (x)+\log (\sin (x))-\frac {1}{2} x \sin (x) \cos (x) \]

[In]

Int[x*Cos[x]^2*Cot[x]^2,x]

[Out]

(-3*x^2)/4 - Cos[x]^2/4 - x*Cot[x] + Log[Sin[x]] - (x*Cos[x]*Sin[x])/2

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 3391

Int[((c_.) + (d_.)*(x_))*((b_.)*sin[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[d*((b*Sin[e + f*x])^n/(f^2*n^
2)), x] + (Dist[b^2*((n - 1)/n), Int[(c + d*x)*(b*Sin[e + f*x])^(n - 2), x], x] - Simp[b*(c + d*x)*Cos[e + f*x
]*((b*Sin[e + f*x])^(n - 1)/(f*n)), x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n, 1]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rule 4493

Int[Cos[(a_.) + (b_.)*(x_)]^(n_.)*Cot[(a_.) + (b_.)*(x_)]^(p_.)*((c_.) + (d_.)*(x_))^(m_.), x_Symbol] :> -Int[
(c + d*x)^m*Cos[a + b*x]^n*Cot[a + b*x]^(p - 2), x] + Int[(c + d*x)^m*Cos[a + b*x]^(n - 2)*Cot[a + b*x]^p, x]
/; FreeQ[{a, b, c, d, m}, x] && IGtQ[n, 0] && IGtQ[p, 0]

Rubi steps \begin{align*} \text {integral}& = -\int x \cos ^2(x) \, dx+\int x \cot ^2(x) \, dx \\ & = -\frac {1}{4} \cos ^2(x)-x \cot (x)-\frac {1}{2} x \cos (x) \sin (x)-\frac {\int x \, dx}{2}-\int x \, dx+\int \cot (x) \, dx \\ & = -\frac {3 x^2}{4}-\frac {\cos ^2(x)}{4}-x \cot (x)+\log (\sin (x))-\frac {1}{2} x \cos (x) \sin (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.04 (sec) , antiderivative size = 33, normalized size of antiderivative = 1.00 \[ \int x \cos ^2(x) \cot ^2(x) \, dx=-\frac {3 x^2}{4}-\frac {1}{8} \cos (2 x)-x \cot (x)+\log (\sin (x))-\frac {1}{4} x \sin (2 x) \]

[In]

Integrate[x*Cos[x]^2*Cot[x]^2,x]

[Out]

(-3*x^2)/4 - Cos[2*x]/8 - x*Cot[x] + Log[Sin[x]] - (x*Sin[2*x])/4

Maple [C] (verified)

Result contains complex when optimal does not.

Time = 2.53 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.82

method result size
risch \(-\frac {3 x^{2}}{4}+\frac {i \left (2 x +i\right ) {\mathrm e}^{2 i x}}{16}-\frac {i \left (-i+2 x \right ) {\mathrm e}^{-2 i x}}{16}-2 i x -\frac {2 i x}{{\mathrm e}^{2 i x}-1}+\ln \left ({\mathrm e}^{2 i x}-1\right )\) \(60\)

[In]

int(x*cos(x)^2*cot(x)^2,x,method=_RETURNVERBOSE)

[Out]

-3/4*x^2+1/16*I*(2*x+I)*exp(2*I*x)-1/16*I*(-I+2*x)*exp(-2*I*x)-2*I*x-2*I*x/(exp(2*I*x)-1)+ln(exp(2*I*x)-1)

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 45, normalized size of antiderivative = 1.36 \[ \int x \cos ^2(x) \cot ^2(x) \, dx=\frac {4 \, x \cos \left (x\right )^{3} - 12 \, x \cos \left (x\right ) - {\left (6 \, x^{2} + 2 \, \cos \left (x\right )^{2} - 1\right )} \sin \left (x\right ) + 8 \, \log \left (\frac {1}{2} \, \sin \left (x\right )\right ) \sin \left (x\right )}{8 \, \sin \left (x\right )} \]

[In]

integrate(x*cos(x)^2*cot(x)^2,x, algorithm="fricas")

[Out]

1/8*(4*x*cos(x)^3 - 12*x*cos(x) - (6*x^2 + 2*cos(x)^2 - 1)*sin(x) + 8*log(1/2*sin(x))*sin(x))/sin(x)

Sympy [F]

\[ \int x \cos ^2(x) \cot ^2(x) \, dx=\int x \cos ^{2}{\left (x \right )} \cot ^{2}{\left (x \right )}\, dx \]

[In]

integrate(x*cos(x)**2*cot(x)**2,x)

[Out]

Integral(x*cos(x)**2*cot(x)**2, x)

Maxima [F(-2)]

Exception generated. \[ \int x \cos ^2(x) \cot ^2(x) \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate(x*cos(x)^2*cot(x)^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: THROW: The catch RAT-ERR is undefined.

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 206 vs. \(2 (27) = 54\).

Time = 0.30 (sec) , antiderivative size = 206, normalized size of antiderivative = 6.24 \[ \int x \cos ^2(x) \cot ^2(x) \, dx=-\frac {6 \, x^{2} \tan \left (\frac {1}{2} \, x\right )^{5} - 4 \, x \tan \left (\frac {1}{2} \, x\right )^{6} - 4 \, \log \left (\frac {16 \, \tan \left (\frac {1}{2} \, x\right )^{2}}{\tan \left (\frac {1}{2} \, x\right )^{4} + 2 \, \tan \left (\frac {1}{2} \, x\right )^{2} + 1}\right ) \tan \left (\frac {1}{2} \, x\right )^{5} + 12 \, x^{2} \tan \left (\frac {1}{2} \, x\right )^{3} - 12 \, x \tan \left (\frac {1}{2} \, x\right )^{4} + \tan \left (\frac {1}{2} \, x\right )^{5} - 8 \, \log \left (\frac {16 \, \tan \left (\frac {1}{2} \, x\right )^{2}}{\tan \left (\frac {1}{2} \, x\right )^{4} + 2 \, \tan \left (\frac {1}{2} \, x\right )^{2} + 1}\right ) \tan \left (\frac {1}{2} \, x\right )^{3} + 6 \, x^{2} \tan \left (\frac {1}{2} \, x\right ) + 12 \, x \tan \left (\frac {1}{2} \, x\right )^{2} - 6 \, \tan \left (\frac {1}{2} \, x\right )^{3} - 4 \, \log \left (\frac {16 \, \tan \left (\frac {1}{2} \, x\right )^{2}}{\tan \left (\frac {1}{2} \, x\right )^{4} + 2 \, \tan \left (\frac {1}{2} \, x\right )^{2} + 1}\right ) \tan \left (\frac {1}{2} \, x\right ) + 4 \, x + \tan \left (\frac {1}{2} \, x\right )}{8 \, {\left (\tan \left (\frac {1}{2} \, x\right )^{5} + 2 \, \tan \left (\frac {1}{2} \, x\right )^{3} + \tan \left (\frac {1}{2} \, x\right )\right )}} \]

[In]

integrate(x*cos(x)^2*cot(x)^2,x, algorithm="giac")

[Out]

-1/8*(6*x^2*tan(1/2*x)^5 - 4*x*tan(1/2*x)^6 - 4*log(16*tan(1/2*x)^2/(tan(1/2*x)^4 + 2*tan(1/2*x)^2 + 1))*tan(1
/2*x)^5 + 12*x^2*tan(1/2*x)^3 - 12*x*tan(1/2*x)^4 + tan(1/2*x)^5 - 8*log(16*tan(1/2*x)^2/(tan(1/2*x)^4 + 2*tan
(1/2*x)^2 + 1))*tan(1/2*x)^3 + 6*x^2*tan(1/2*x) + 12*x*tan(1/2*x)^2 - 6*tan(1/2*x)^3 - 4*log(16*tan(1/2*x)^2/(
tan(1/2*x)^4 + 2*tan(1/2*x)^2 + 1))*tan(1/2*x) + 4*x + tan(1/2*x))/(tan(1/2*x)^5 + 2*tan(1/2*x)^3 + tan(1/2*x)
)

Mupad [B] (verification not implemented)

Time = 24.45 (sec) , antiderivative size = 56, normalized size of antiderivative = 1.70 \[ \int x \cos ^2(x) \cot ^2(x) \, dx=\ln \left ({\mathrm {e}}^{x\,2{}\mathrm {i}}-1\right )-{\mathrm {e}}^{-x\,2{}\mathrm {i}}\,\left (\frac {1}{16}+\frac {x\,1{}\mathrm {i}}{8}\right )+{\mathrm {e}}^{x\,2{}\mathrm {i}}\,\left (-\frac {1}{16}+\frac {x\,1{}\mathrm {i}}{8}\right )-\frac {3\,x^2}{4}-x\,2{}\mathrm {i}-\frac {x\,2{}\mathrm {i}}{{\mathrm {e}}^{x\,2{}\mathrm {i}}-1} \]

[In]

int(x*cos(x)^2*cot(x)^2,x)

[Out]

log(exp(x*2i) - 1) - x*2i - exp(-x*2i)*((x*1i)/8 + 1/16) + exp(x*2i)*((x*1i)/8 - 1/16) - (x*2i)/(exp(x*2i) - 1
) - (3*x^2)/4